package com.ruoyi.bathrooms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bathrooms.domain.Bathrooms;
import com.ruoyi.bathrooms.service.IBathroomsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房间卫所管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/bathrooms/bathrooms")
public class BathroomsController extends BaseController
{
    @Autowired
    private IBathroomsService bathroomsService;

    /**
     * 查询房间卫所管理列表
     */
    @PreAuthorize("@ss.hasPermi('bathrooms:bathrooms:list')")
    @GetMapping("/list")
    public TableDataInfo list(Bathrooms bathrooms)
    {
        startPage();
        List<Bathrooms> list = bathroomsService.selectBathroomsList(bathrooms);
        return getDataTable(list);
    }

    /**
     * 导出房间卫所管理列表
     */
    @PreAuthorize("@ss.hasPermi('bathrooms:bathrooms:export')")
    @Log(title = "房间卫所管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Bathrooms bathrooms)
    {
        List<Bathrooms> list = bathroomsService.selectBathroomsList(bathrooms);
        ExcelUtil<Bathrooms> util = new ExcelUtil<Bathrooms>(Bathrooms.class);
        util.exportExcel(response, list, "房间卫所管理数据");
    }

    /**
     * 获取房间卫所管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('bathrooms:bathrooms:query')")
    @GetMapping(value = "/{bathroomId}")
    public AjaxResult getInfo(@PathVariable("bathroomId") Long bathroomId)
    {
        return success(bathroomsService.selectBathroomsByBathroomId(bathroomId));
    }

    /**
     * 新增房间卫所管理
     */
    @PreAuthorize("@ss.hasPermi('bathrooms:bathrooms:add')")
    @Log(title = "房间卫所管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Bathrooms bathrooms)
    {
        return toAjax(bathroomsService.insertBathrooms(bathrooms));
    }

    /**
     * 修改房间卫所管理
     */
    @PreAuthorize("@ss.hasPermi('bathrooms:bathrooms:edit')")
    @Log(title = "房间卫所管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Bathrooms bathrooms)
    {
        return toAjax(bathroomsService.updateBathrooms(bathrooms));
    }

    /**
     * 删除房间卫所管理
     */
    @PreAuthorize("@ss.hasPermi('bathrooms:bathrooms:remove')")
    @Log(title = "房间卫所管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bathroomIds}")
    public AjaxResult remove(@PathVariable Long[] bathroomIds)
    {
        return toAjax(bathroomsService.deleteBathroomsByBathroomIds(bathroomIds));
    }
}
